Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(link-editor): update behaviour so that we can save on link collection items #863

Merged
merged 28 commits into from
Nov 16, 2024

Conversation

seaerchin
Copy link
Contributor

@seaerchin seaerchin commented Nov 7, 2024

Problem

This PR fixes an issue with ISOM-1654 (and more deeply, the link editor)

Closes ISOM-1654

Solution

  1. add a LinkEditorContext that all the child components read from. we do this so that the state can be unified for what the href currently is + the currently active link item
  2. pass onChange to the context and have the children reference it. this isn't quite ideal yet because page/file elements live outside of the context but we're manually passing the same onChange + callsite is limited, this shuold be ok
  3. fix overflow for ref control so that overflowing links display as truncated elllipsis
  4. bug-fix for tab behaviour so that doing any action on any other radio tab resets the state but changing the radio itself doesn't reset the state

Videos + Screenshots

Screen.Recording.2024-11-07.at.1.00.27.PM.mov
image

overflow now

@seaerchin seaerchin requested a review from a team as a code owner November 7, 2024 04:59
Copy link

vercel bot commented Nov 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 16, 2024 9:44am

Copy link

linear bot commented Nov 7, 2024

@opengovsg opengovsg deleted a comment from linear bot Nov 7, 2024
@seaerchin seaerchin changed the title Fix/file collections fix(link-editor): update behaviour so that we can save on link collection items Nov 7, 2024
Copy link

linear bot commented Nov 7, 2024

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 7, 2024

Datadog Report

Branch report: fix/file-collections
Commit report: 83aaec4
Test service: isomer-studio

✅ 0 Failed, 184 Passed, 34 Skipped, 39.63s Total Time
➡️ Test Sessions change in coverage: 1 no change

@adriangohjw
Copy link
Contributor

for tab behaviour so that doing any action on any other radio tab resets the state but changing the radio itself doesn't reset the state

will this be confusing UX? because it's not obvious to the end user why and when it resets

@seaerchin
Copy link
Contributor Author

for tab behaviour so that doing any action on any other radio tab resets the state but changing the radio itself doesn't reset the state

will this be confusing UX? because it's not obvious to the end user why and when it resets

yeap, getting @sehyunidaaa to double check this but i thought this was intuitive because:

  1. swapping tabs doesn't do anything
  2. taking an action resets

@sehyunidaaa
Copy link
Contributor

Just to confirm - we had to use this logic of resetting only when there's a change because it's difficult to maintain the input across different tabs right (E.g., if file has an attachment and link also has a link, we can't keep the two)

But I agree with Chin on this, I think once the user inputs something in a different tab then it's a signal that they want to link something else

Comment on lines +202 to +208
linkTypes: Record<
string,
{
icon: IconType
label: Capitalize<LinkTypes>
}
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use LinkTypeMapping instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually tried this and it didn't quite work. this is because when we say Record<LinkTypes, string>, actually what we mean is a 1:1 mapping (ie, every type in LinkType must have a corresponding string) which isn't quite what we want here. what we want is "some subset of LinkTypes to string" - i considered using Partial<Record<LinkTypes, string>>, but unfortunately that means that every type is now optional. hence, i just went iwth string for now

apps/studio/src/components/PageEditor/LinkEditorModal.tsx Outdated Show resolved Hide resolved
@seaerchin seaerchin merged commit ed8abff into main Nov 16, 2024
18 of 21 checks passed
@seaerchin seaerchin deleted the fix/file-collections branch November 16, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants